Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

484
Vistas
(moduleNameMapper not applied) Vue jest configuration error: "Could not locate module @/javascript/app.vue mapped as:"

I have a Vue2 Rails application and tried to install Jest which worked. The problem is that I cannot test my components because of this error:

  ● Test suite failed to run

    Configuration error:
    
    Could not locate module @/app.vue mapped as:
    /Users/name/project/project-name/src/app.vue.
    
    Please check your configuration for these entries:
    {
      "moduleNameMapper": {
        "/^@\/(.*)$/": "/Users/name/project/project-name/src/$1"
      },
      "resolver": null
    }

Which makes sense, because my component is in /Users/name/project/project-name/app/javascript/app.vue and there is no src directory in my project, because it is a Rails app.

But in my package.json I added

"jest": {
    "moduleNameMapper": {
      "^@/(.*)$": "<rootDir>/app/javascript/$1"
    },
    "preset": "@vue/cli-plugin-unit-jest/presets/no-babel"
  }

Which obviously does not work. Putting all of it into a src folder also does not work. I feel like I'm missing some crucial configuration.

Edit: Alright, I went in and changed my moduleNameMapper by hand which is definitely not how this should be done, but I couldn't get it to work otherwise. In node_modules/jest-resolve/build/index.js at line 121 I wrote

this._options.moduleNameMapper[0].moduleName = "/Users/name/project/project-name/app/javascript/$1";

I don't have time to figure out the real issue right now. I will come back when I have the real solution.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda